%include "asm_io.inc"

segment .data
;
;initialized data is put in the data segment here
;

prompt1 db "Give 1st char:	",0	;initialize the messages
prompt2 db "Give 2nd char:	",0
prompt3 db "Give 3rd char:	",0
prompt4 db "Give 4th char:	",0
prompt5 db "Give 5th char:	",0
outmsg1	db ",",0
outmsg2	db 10,0				;ascii for newline

segment .bss
;
;uninitialized data is put in the bss segment
;

input1 resd 1
input2 resd 1
input3 resd 1
input4 resd 1
input5 resd 1

segment .text
;
;code here
;

	global asm_main

asm_main:
	enter 0,0		;setup routine
	pusha

	mov eax, prompt1	;print out 1st prompt
	call print_string

	call read_char		;read char
	mov [input1],eax	;store into input1
	call read_char		;get rid of the enter

	mov eax, prompt2
	call print_string

	call read_char		
	mov [input2],eax	
	call read_char		;get rid of the enter

	mov eax, prompt3
	call print_string
	
	call read_char		
	mov [input3],eax	
	call read_char		;get rid of the enter

	mov eax, prompt4
	call print_string

	call read_char		
	mov [input4],eax	
	call read_char		;get rid of the enter

	mov eax, prompt5
	call print_string

	call read_char		
	mov [input5],eax

	mov eax, [input5]	;prepare 5th char
	call print_char		;print it out

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input4]	;prepare 4th char
	call print_char		;print it out

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input3]	;prepare 3rd char
	call print_char		;print it out

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input2]	;prepare 2nd char
	call print_char		;print it out

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input1]	;prepare 1st char
	call print_char		;print it out
	
	mov eax, outmsg2	;prepare a newline
	call print_string	;print it out

	popa
	mov eax,0	;return back to C
	leave
	ret
